<script setup>
import {ref,watch} from 'vue'
//文件预览
defineOptions({
  name:'FilePreview'
})
const props=defineProps({
  fileUrl:{
    type:String,
    default:''
  },
  useOffice:{
    type:Boolean,
    default:false
  }
})
const url=ref('about:blank')
const siteUrlReg=/^https?:\/\/\w+\.\w+/
const setUrl=()=>{
  if(props.fileUrl){
    let fileUrl=props.fileUrl;
    let page = import.meta.resolve("../js/file-viewer/index.html")+'?fileUrl='+encodeURIComponent(fileUrl)
    if(props.useOffice){
      page+='&useOfficeMicroOnline=true'
    }
    url.value=page
  }
}
setUrl()
watch(()=>props.fileUrl,()=>setUrl())

</script>

<template>
<iframe :src="url" style="width: 100%;min-height: 100px;border: none;overflow: auto"></iframe>
</template>

<style scoped>

</style>
